import com.sun.xml.internal.bind.v2.runtime.RuntimeUtil;

import java.util.Arrays;
import java.util.Comparator;

class Student implements Comparable<Student>,Cloneable{
    int age;

    String name;

    public Student(int age, String name) {
        this.age = age;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }


    @Override
    public int compareTo(Student o) {
        return this.age-o.age;
    }


    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}


class AgeComparator implements Comparator<Student>{

    @Override
    public int compare(Student o1, Student o2) {
        return o1.age- o2.age;
    }
}


class NameComparator implements Comparator<Student>{

    @Override
    public int compare(Student o1, Student o2) {
        return o1.name.compareTo(o2.name);
    }
}


class Money implements Cloneable{
    public double mon=19.9;

    @Override
    public String toString() {
        return ""+ mon;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}



class People implements Cloneable{
    String name;

    Money money;

    public People(String name) {
        this.name = name;
        this.money=new Money();
    }

    @Override
    public String toString() {
        return "People{" +
                "name=" + name +
                ", money=" + money +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        People temp=(People) super.clone();
        temp.money=(Money) this.money.clone();
        return temp;
    }
}







public class Main {
    public static void main(String[] args) throws CloneNotSupportedException {
        /*Student[] students=new Student[3];
        students[0]=new Student(15,"zhangsan");
        students[1]=new Student(10,"lisi");
        students[2]=new Student(18,"wangwu");

        Arrays.sort(students);
        System.out.println(Arrays.toString(students));

        AgeComparator ageComparator=new AgeComparator();
        System.out.println(ageComparator.compare(students[0], students[1]));

        NameComparator nameComparator=new NameComparator();
        System.out.println(nameComparator.compare(students[0], students[1]));
*/

        /*Student student1=new Student(100,"zhaolui");
        Student student2=student1;
        System.out.println(student1);
        System.out.println(student2);

        student1.age=200;
        System.out.println(student1);
        System.out.println(student2);*/


        /*Student student1=new Student(100,"zhaolui");
        Student student2=(Student) student1.clone();
        System.out.println(student1);
        System.out.println(student2);

        *//*student1.age=200;
        System.out.println(student1);
        System.out.println(student2);*//*

        student1.name="zhangsan";
        System.out.println(student1);
        System.out.println(student2);
*/

        People people1=new People("zhangsan");
        People people2=(People) people1.clone();
        System.out.println(people1);
        System.out.println(people2);

        /*people1.name="lisi";
        System.out.println(people1);
        System.out.println(people2);*/


        people1.money.mon=50;
        System.out.println(people1);
        System.out.println(people2);
    }
}